import {defineStore} from "pinia";

export let useAStore = defineStore("a",{
    state:()=>({
        a:10,
    }),
    getters:{
        doubleA:function(state){
            console.log("docubleA取值成功",state,this);
            return state.a * 2;
        },
        tripleA:function(state){
            return state.a * 3;
        }
    },
    actions:{
        addA:function(){
            // this -> 当前store实例   store.a  state.docubleA store.addA
            this.a ++;
        },
        addA_Async(){
            return new Promise((resolve)=>{
                setTimeout(()=>{
                    this.a++;
                    resolve()
                },2000);
            })
        }
    }
});